package com.xz.stu.server.controller;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import com.xz.stu.server.entity.ScheduleTimeSlot;
import com.xz.stu.server.service.ScheduleTimeSlotService;
import com.xz.stu.server.vo.scheduleTimeSolt.TimeSlotCreateReqVO;
import com.xz.stu.server.vo.scheduleTimeSolt.TimeSlotPageReqVO;
import com.xz.stu.server.vo.scheduleTimeSolt.TimeSlotUpdateReqVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("admin-api/school/time-slot")
@Validated
public class TimeSlotController {

    @Resource
    private ScheduleTimeSlotService scheduletimeSlotService;

    @PostMapping("/create")
    public CommonResult<Long> createTimeSlot(@RequestBody TimeSlotCreateReqVO createReqVO) {
        return CommonResult.success(scheduletimeSlotService.createTimeSlot(createReqVO));
    }

    @PutMapping("/update")
    public CommonResult<Boolean> updateTimeSlot( @RequestBody TimeSlotUpdateReqVO updateReqVO) {
        scheduletimeSlotService.updateTimeSlot(updateReqVO);
        return CommonResult.success(true);
    }

    @DeleteMapping("/delete")
    public CommonResult<Boolean> deleteTimeSlot(@RequestParam("id") Long id) {
        scheduletimeSlotService.deleteTimeSlot(id);
        return CommonResult.success(true);
    }

    @GetMapping("/get")
    public CommonResult<ScheduleTimeSlot> getTimeSlot(@RequestParam("id") Long id) {
        return CommonResult.success(scheduletimeSlotService.getTimeSlot(id));
    }

    @GetMapping("/page")
    public CommonResult<PageResult<ScheduleTimeSlot>> getTimeSlotPage(@Valid TimeSlotPageReqVO pageVO) {
        return CommonResult.success(scheduletimeSlotService.getTimeSlotPage(pageVO));
    }

    @GetMapping("/list-all")
    public CommonResult<List<ScheduleTimeSlot>> getAllTimeSlots() {
        return CommonResult.success(scheduletimeSlotService.getAllTimeSlots());
    }
}
